<html>
<head>
    <title>@yield('title')</title>
    <meta charset="utf-8"/>
    <meta name="keywords" content=""/>
    <meta name="description" content=""/>
    <meta name="viewport" content="width=device-width"/>
    <link rel="stylesheet" href="/assert/css/style.css?v=2"/>
    <link rel="stylesheet" href="/assert/css/site.css?v=avs7788"/>
    <script
            src="http://code.jquery.com/jquery-1.12.4.min.js"
            integrity="sha256-ZosEbRLbNQzLpnKIkEdrPv7lOy9C27hHQ+Xp8a4MxAQ="
            crossorigin="anonymous"></script>
    <style>
        .send_msg{
            color: #0E6990;
            font-size: 20px;
        }
    </style>
</head>
<body>
    @yield('content')

    <div class="container">
        <div class="contact_us f-fl">
            <div class="box-title">
                <span>联系我们/contact us</span>
            </div>
            <div class="form">
                <form action="" method="post">
                    <div class="row">
                        <input type="text" name="email" class="input-email" placeholder="Email*">
                        <input type="text" name="name"  class="input-name" placeholder="Name*">
                    </div>
                    <div class="row">
                        <input type="text" name="subject" class="input-subject" placeholder="Subject">
                    </div>
                    <div class="row">
                        <textarea  class="input-message" name="message" placeholder="Message" ></textarea>
                    </div>
                    <div class="row">
                        <input type="button" value="Send" class="submit send_msg">
                    </div>
                    <div class="error_div" >
                        <br>
                        <span style="margin-left: 200px;color: #C71212;margin-top: 10px "></span>
                    </div>
                </form>
            </div>
        </div>
        <div class="address f-fl" style="margin-top: 30px">
            <div>
                <p class="p2">
                    微信搜索EducationExpress1<br/>
                    或扫二维码添加客服微信：
                </p>

                <img src="/assert/img/wx.png">
            </div>

        </div>
        <div class="f-cb"></div>
    </div>
    <script>
        $(".form .submit").click(function(){
            var email = $.trim($(".input-email").val());
            var name  = $.trim($(".input-name").val());
            var subject = $.trim($(".input-subject").val());
            var message = $.trim($(".input-message").val());

            if(email ==""){
                $(".error_div span").text('请填写邮箱');
                return false;
            }
            var myreg  = /^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
            if(!myreg.test(email)){
                $(".error_div span").text('请填写正确的邮箱');
                return false;
            }
            if(name ==""){
                $(".error_div span").text('请填写姓名');
                return false;
            }

            $(".error_div span").text('');

            $.post('/message',{email:email,name:name,subject:subject,message:message},function (req) {
                if(req.status==0){
                    $(".error_div span").text(req.errMsg);
                }else{
                    alert('留言成功');
                    $(".error_div span").text('');
                }
            },'json')
        });
    </script>
</body>
</html>